/*
定义顺序队列，以及基本操作
*/

#include <iostream>

using namespace std;

typedef int ElementType;

typedef struct Queue Queue;
struct Queue {
    ElementType *data;
    int front, rear, maxSize;
};

// 初始化队列
Queue *init(int n) {
    Queue *queue = new Queue;
    queue->data = new ElementType[n + 1];
    queue->front = queue->rear = 0;
    queue->maxSize = n + 1;
    return queue;
}

// 判断队列是否为空
bool isEmpty(Queue *queue) { return queue->front == queue->rear; }

// 判断队列是否已满
bool isFull(Queue *queue) {
    return (queue->rear + 1) % queue->maxSize == queue->front;
}

// 入队
bool enQueue(Queue *queue, ElementType x) {
    if (isFull(queue)) {
        return false;
    }
    queue->data[queue->rear] = x;
    queue->rear = (queue->rear + 1) % queue->maxSize;
    return true;
}

// 出队
ElementType deQueue(Queue *queue) {
    if (isEmpty(queue)) {
        return -1;
    }
    ElementType x = queue->data[queue->front];
    queue->front = (queue->front + 1) % queue->maxSize;
    return x;
}

// 取队首元素
ElementType front(Queue *queue) {
    if (isEmpty(queue)) {
        return -1;
    }
    return queue->data[queue->front];
}